public class PhoneNumbers
{
   /**
      Cleans a phone number.
      @param phoneNumber a phone number that should contain ten digits and possibly other characters
      @return the phone number in the form (###) ###-#### or the string "Error" if phoneNumber
      does not have ten digits
   */
   public String cleanNumber(String phoneNumber)
   {   
      // your work here
      int l = phoneNumber.length(),num = 0;
      String ss = "(";
      for (int i = 0; i < l; i++)
      {
         char ch = phoneNumber.charAt(i);
         if (Character.isDigit(ch))
         {
            num++;
            ss += ch;
            if(num == 3)
            ss += ") ";
            if(num == 6)
            ss += "-";
         }          
      }
      if(num==10)
      return ss;
      else
      return "Error";
   }   
}